import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ProvinceVO, ProvinceForm, ProvinceQuery } from '@/api/credit/area/province/types';

/**
 * 查询全国的 省份列表
 * @param query
 * @returns {*}
 */

export const listProvince = (query?: ProvinceQuery): AxiosPromise<ProvinceVO[]> => {
  return request({
    url: '/credit/province/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询全国的 省份详细
 * @param id
 */
export const getProvince = (id: string | number): AxiosPromise<ProvinceVO> => {
  return request({
    url: '/credit/province/' + id,
    method: 'get'
  });
};

/**
 * 新增全国的 省份
 * @param data
 */
export const addProvince = (data: ProvinceForm) => {
  return request({
    url: '/credit/province',
    method: 'post',
    data: data
  });
};

/**
 * 修改全国的 省份
 * @param data
 */
export const updateProvince = (data: ProvinceForm) => {
  return request({
    url: '/credit/province',
    method: 'put',
    data: data
  });
};

/**
 * 删除全国的 省份
 * @param id
 */
export const delProvince = (id: string | number | Array<string | number>) => {
  return request({
    url: '/credit/province/' + id,
    method: 'delete'
  });
};
